package com.xuecheng.content.api;

import com.xuecheng.content.mapper.CourseTeacherMapper;
import com.xuecheng.content.model.dto.AddTeacherDto;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "教师管理接口")
public class TeacherController {

    @Autowired
    private CourseTeacherService courseTeacherService;

    @GetMapping("/courseTeacher/list/{id}")
    @ApiOperation("根据课程id查询教师信息")
    public List<CourseTeacher> getTeacherListByCourseId(@PathVariable Long id) {
        List<CourseTeacher> teachersList = courseTeacherService.getTeacherListByCourseId(id);
        return teachersList;
    }

    @PostMapping("/courseTeacher")
    @ApiOperation("添加教师")
    public CourseTeacher saveOrUpdateTeacher(@RequestBody AddTeacherDto TeacherDto) {
        //机构id，由于认证系统没有上线暂时硬编码
        Long companyId = 1232141425L;
        CourseTeacher courseTeacher = courseTeacherService.saveOrUpdateTeacher(TeacherDto, companyId);
        return courseTeacher;
    }

    @DeleteMapping("/courseTeacher/course/{courseId}/{teacherId}")
    @ApiOperation("删除教师")
    public void deleteTeacher(@PathVariable Long courseId, @PathVariable Long teacherId) {
//机构id，由于认证系统没有上线暂时硬编码
        Long companyId = 1232141425L;
        courseTeacherService.deleteTeacher(courseId, teacherId, companyId);

    }
}